﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DingHeng.TransportationManagement.Entity;

namespace DingHeng.TransportationManagement.DataAccess
{
    public class DriverDataAccess : DAOBase<Driver>
    {
        public int Save(Driver entity)
        {
            using (this.context = new TransportationManagementContext())
            {
                var oldEntity = this.context.Drivers.Where(a => a.ID == entity.ID).FirstOrDefault();
                if (oldEntity != null)
                {
                    this.Update(oldEntity, entity);
                }
                else
                {
                    this.Insert(entity);
                }
                return this.SaveChanges();
               
            }
        }
    }
}
